package com.shinheungcal.Fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;

import com.shinheungcal.R;
import com.shinheungcal.ResultActivity;
import com.shinheungcal.IO.GearSpac;

public class f_Cal1InputPage extends Fragment {

	private GearSpac spac;
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		getActivity().invalidateOptionsMenu();
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		setHasOptionsMenu(true);
		View rootView = inflater.inflate(R.layout.f_cal1_input, null);
		
		return rootView;
		
	}
	
	@Override
	public void onPrepareOptionsMenu(Menu menu) {
		menu.findItem(R.id.cal1_result).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		
		if (item.getItemId() == R.id.cal1_result) {
			Intent intent = new Intent(getActivity(), ResultActivity.class);
			intent.putExtra("item", spac);
			startActivity(intent);
		}
		
		return true;
	}
}
